package cn.edu.ctbu.datajpa1.repository;

import ch.qos.logback.core.model.INamedModel;
import cn.edu.ctbu.datajpa1.domain.Teacher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TeacherRepository extends JpaRepository<Teacher,Integer> {
    List<Teacher> findByNameLike(String name);

    @Query("select t from tb_teacher t where substring(t.tno,1,4) ="+
            "(select substring(MAX(t1.tno),1,4)from tb_teacher t1 group by substring(t1.tno,1,4)having count(*)>1)")

    List<Teacher> findTeacherWithSamePrefix();






}
